home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2966 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: gsf.de!news
  2. From: Guido Kraus <guido.kraus@gsf.de>
  3. Newsgroups: comp.lang.c
  4. Subject: C time/date to Visual Basic time/date
  5. Date: 25 Jan 1996 08:31:32 GMT
  6. Organization: GSF
  7. Message-ID: <4e7f54$71t@cony.gsf.de>
  8. NNTP-Posting-Host: pc1676.gsf.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  13.  
  14. My problem:
  15.  
  16. I'm currently working on a DLL which has to work together with Visual 
  17. Basic. I'd like to return a date/time variable to Basic. Unfortunately 
  18. Basic stores a date as days since 12/30/1899 (double variable; the 
  19. fractional part represents hours, minutes and seconds) and C stores it as 
  20. seconds since 01/01/1970 (long variable).
  21.  
  22. I thought this would be easy and calculated the difference between these 
  23. two dates in seconds, added the number of seconds to a C variable of type 
  24. 'time_t' (long) and then devided this by 86400 (number of seconds of a 
  25. day).
  26.  
  27.   {
  28.   .
  29.   .
  30.   time_t timer;
  31.   double VBtime;
  32.  
  33.   /* get current system time */
  34.   time(&timer);
  35.  
  36.   /* VB_SECONDS = secs between 12/30/1899 and 1/1/1970 */
  37.   VBtime=(double)(timer+VB_SECONDS); 
  38.   VBtime=(double)(timer/86400L);
  39.   .
  40.   .
  41.   }
  42.  
  43. I calculated VB_SECONDS in Visual Basic and got 2209125600. But it 
  44. doesn't work this way.
  45. If there is someone out there who has a solution, please give me a hint.
  46.  
  47. TIA,
  48. Guido
  49.  
  50.